package com.xkcyy.one.core.security;

import lombok.Data;

/**
 * 系统身份凭证
 */
@Data
public class SysIdentity {
    private Long id;
    private String name;
    private String code;
    private String token;

    private static final ThreadLocal<SysIdentity> contextHolder = new ThreadLocal<>();

    /**
     * 设置当前身份凭证
     */
    public static void setCurrent(SysIdentity identity) {
        contextHolder.set(identity);
    }

    /**
     * 获取当前身份凭证
     */
    public static SysIdentity current() {
        return contextHolder.get();
    }

    /**
     * 清除当前身份凭证
     */
    public static void clear() {
        contextHolder.remove();
    }
} 